package org.zpmis.api.http;

import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zpmis.api.business.StatisticsWebService;
import org.zpmis.common.base.BaseController;
import org.zpmis.common.exception.BusinessException;
import org.zpmis.common.result.PlatformResult;
import org.zpmis.domain.customer.qo.StatisticsQo;

import javax.annotation.Resource;

/**
* created with CodeGenerator
* description: 统计操作接口
* @author  Yang
* date: 2021-6-2
* time: 14:53:29
*/
@RestController
@RequestMapping("/statistics")
@Slf4j
public class StatisticsController extends BaseController{

    @Resource
    private StatisticsWebService statisticsWebService;


    /**
     * 统计漏斗图
     * @param statisticsQo
     * @return
     */
    @PostMapping("/funnelStatistics")
    public PlatformResult funnelStatistics(@Validated @RequestBody StatisticsQo statisticsQo){
        try {
            return PlatformResult.success(statisticsWebService.funnelStatistics(statisticsQo));
        } catch (BusinessException e) {
            log.error("[ProjectController]---funnelStatistics--->BusinessException:",e);
            return PlatformResult.failure(e.getResultCode());
        } catch (Exception e) {
            log.error("[ProjectController]---funnelStatistics--->Exception:",e);
            return PlatformResult.failure();
        }
    }

    /**
     * 意向有效率
     * @param statisticsQo
     * @return
     */
    @PostMapping("/intentEfficient")
    public PlatformResult intentEfficient(@Validated @RequestBody StatisticsQo statisticsQo){
        try {
            return PlatformResult.success(statisticsWebService.intentEfficient(statisticsQo));
        } catch (BusinessException e) {
            log.error("[ProjectController]---intentEfficient--->BusinessException:",e);
            return PlatformResult.failure(e.getResultCode());
        } catch (Exception e) {
            log.error("[ProjectController]---intentEfficient--->Exception:",e);
            return PlatformResult.failure();
        }
    }


}
